/**
 * Created by wzq on 15-3-28.
 */

var mongodb = require('./mongodb.js');
var Schema = mongodb.Schema;

var shareSchema = new Schema({
  author_id: String,
  author_name: String,
  author_avatar: String,

  comment_count: Number,
  score_count: Number,
  score_sum: Number,

  //
  content: String,
  link: String,
  tag: Array,
  verify_status: String,
  en_comment: Boolean,
  en_score: Boolean,

  //
  created_at: Date,
  updated_at: {
    type: Date,
    default: Date.now
  }

});

shareSchema.pre('save', function(next) {
  var currentDate = new Date();
  if (!this.created_at) {
    this.created_at = currentDate;
  }
  next();
});

var Share = mongodb.model('Share', shareSchema);

module.exports = Share;
